package com.security.hikapp.network.exception;


import io.reactivex.rxjava3.functions.Consumer;

/**
 * 要用处理异常回调的Consumer
 */
public abstract class ErrorConsumer<T> implements Consumer<Throwable> {

    @Override
    public void accept(Throwable throwable) {
        ApiException ex;
        if (throwable instanceof ApiException){
            ex = (ApiException) throwable;
        }else {
            ex = ApiException.handleException(throwable);
        }
        error(ex);
    }

    protected abstract void error(ApiException ex);
}
